#include "stdafx.h"
#include "Racket.h"

Racket::Racket (){
	this->height = 50;
	this->width = 20;
}

void Racket::setXPos(unsigned int value){
	this->xPos = value;
}

void Racket::setYPos(unsigned int value){
	this->yPos = value;
}

unsigned int Racket::getXPos(){
	return this->xPos;
}

unsigned int Racket::getYPos(){
	return this->yPos;
}

void Racket::setColor(unsigned int hue){
	this->hue = hue;
}

void Racket::setWidth (int width){
	this->width = width;
}

int Racket::getWidth() {
	return width;
}

void Racket::setHeight (int height){
	this->height = height;
}

int Racket::getHeight() {
	return height;
}

bool Racket::bounding_box(int b1_x, int b1_y, int b1_w, int b1_h, int b2_x, int b2_y, int b2_w, int b2_h)
{
	/*if(b2_x == b1_x && ((b1_y > b2_y - b1_h/2)&&(b1_y < b2_y + b1_h/2))){
		return true;
	}
	return false;*/

	if ((b1_x > b2_x + b2_w - 1) || 
	(b1_y > b2_y + b2_h - 1) ||  
	(b2_x > b1_x + b1_w - 1) ||  
	(b2_y > b1_y + b1_h - 1))         
	{
		return false;
	}

	return true;
}

void Racket::checkCollision(Ball &B)
{
    if (bounding_box(xPos, yPos - height/2, width, height, B.getX(), B.getY(), B.getRadius(), B.getRadius()))
	{
        B.bounce(false);
		}
}

